package cn.com.chengmandian.service.erp.constants;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public enum BatteryChangeBusinessTypeEnum {
    BS(11,"备品新发货", 1, 1),
    BC(12,"备品拨出", 2, 1),
    BR(13,"备品拨入", 1, 1),
    BD(14,"备品丢失", 2, 1),
    BF(15,"备品报废", 2, 1),
    BO(16,"备品->客户转出", 2, 1),
    CS(31,"客户新发货", 1, 2),
    CD(32,"客户报失", 2, 2),
    CI(33,"备品-客户转入", 1, 2);

    private Integer code;

    private String name;

    private Integer inoutType; // 1-入库 2-出库

    private Integer objectType; // 1-仓库 2-客户

    public Integer getCode() {
        return this.code;
    }

    public String getName() {
        return this.name;
    }

    public Integer getInoutType() {
        return this.inoutType;
    }

    public Integer getObjectType() {
        return this.objectType;
    }

    BatteryChangeBusinessTypeEnum(Integer code, String name, Integer inoutType, Integer objectType) {
        this.code = code;
        this.name = name;
        this.inoutType = inoutType;
        this.objectType = objectType;
    }

    public static BatteryChangeBusinessTypeEnum getByCode(Integer code) {
        if (code == null) return null;
        for(BatteryChangeBusinessTypeEnum item : BatteryChangeBusinessTypeEnum.values()) {
            if (code.equals(item.getCode())) return item;
        }
        return null;
    }

    public static JSONArray getBasedata() {
        JSONArray res = new JSONArray();
        for(BatteryChangeBusinessTypeEnum item : BatteryChangeBusinessTypeEnum.values()) {
            JSONObject i = new JSONObject();
            i.put("name", item.getName());
            i.put("value", item.getCode());
            i.put("type", item.getObjectType());
            res.add(i);
        }
        return res;
    }
}
